<template>
  <div class="con">
    <div class="lwy-back">
      <router-link to="/happyhome/leisure/keepinglive"><i class="el-icon-arrow-left"></i>返回首页</router-link>
    </div>

    <div class="jielu">

      <router-link to="/HappyHome/leisure/keedaka" style="text-decoration: none;">
        <p>体重记录</p>
      </router-link>
      <router-link to="/happyhome/leisure/keeweight" style="text-decoration: none;">
        <p>运动记录</p>
      </router-link>
    </div>
    <!-- 计时器 -->
    <div class="father">
      <div class="time">计时器：</div>
      <el-button type="primary" @click="startHandler">开始</el-button>
      <ul>
        <li><b>{{ one }}<span>:</span></b></li>
        <li><b>{{ two }}<span>:</span></b></li>
        <li><b>{{ three }}</b></li>

      </ul>

      <el-button type="primary" @click="endHandler">暂停</el-button>
    </div>
    <div class="contain">


      <div class="tab">
        <div class="tab-title" v-for="(item, index) in woman" :key="index">
          <div class="aa">
            <div>
              <el-button :class="['tab-item', activeIndex === index ? 'change' : '']" @click="btnClick(index)">
                {{ item.name }}
              </el-button>

            </div>
          </div>
        </div>
      </div>

      <div class="main">

        <div class="sub-main" v-for="(item, index) in subFoodList" :key="index">

          <div class="img">
            <!-- <img :src="item.img"> -->
            <video muted="muted" class="video" :src="item.path" type="video/mp4" :img="item.url" autoplay:false
              controls="controls" loop="-1">
            </video>



            <div class="itt">
                {{ item.font }}
              <p>{{ item.font2 }}</p>

            </div>
            <router-link to="/happyhome/work/clocks">
              <el-button @click="butn" type="button" class="el-button--primary">完成训练</el-button>
            </router-link>
          </div>

        </div>

      </div>
    </div>
    <div>

    </div>
  </div>
</template>

<script>
import axios from 'axios';
export default {
  data() {
    return {
      // 计时器
      flag: null,
      one: '00', // 时
      two: '00', // 分
      three: '00', // 秒
      abc: 0, // 秒的计数
      cde: 0, // 分的计数
      efg: 0, // 时的计数
      activeIndex: 0,
      index: 0,
      a1: true,
      show: true,
      drawer: false,
      // deadline3: Date.now() + 1000 * 60 * 30,
      deadline4: Date.now(),
      stop: true,
      value: '',
      // 假设后端返回的数组对象
      woman: [
        {
          children: [
            {

            },
          ],
        },

      ],
      // 二级内容
      subFoodList: [],
      // 默认索引 0
      activeIndex: 0,
      woman: []
    }
  },
  methods: {
    // 
    butn() {
      alert('太厉害了，继续保持，快去记录一下吧！！！')
    },
    // 开始计时
    startHandler() {
      this.flag = setInterval(() => {
        if (this.three === 60 || this.three === '60') {
          this.three = '00';
          this.abc = 0;
          if (this.two === 60 || this.two === '60') {
            this.two = '00';
            this.cde = 0;
            if (this.efg + 1 <= 9) {
              this.efg++;
              this.one = '0' + this.efg;
            } else {
              this.efg++;
              this.one = this.efg;
            }
          } else {
            if (this.cde + 1 <= 9) {
              this.cde++;
              this.two = '0' + this.cde;
            } else {
              this.cde++;
              this.two = this.cde;
            }
          }
        } else {
          if (this.abc + 1 <= 9) {
            this.abc++;
            this.three = '0' + this.abc;
          } else {
            this.abc++;
            this.three = this.abc;
          }
        }

      }, 1000)
    },
    // 暂停计时
    endHandler() {
      this.flag = clearInterval(this.flag)
    },
    onSubmit() {
      console.log('submit!');
    },
    open() {
      this.$notify({
        title: 'ok',
        message: '为你增加+60秒',
        type: 'success',
        position: 'bottom-right',
        duration: 600,
      })
    },

    hilarity() {
      this.$notify({
        title: '提示',
        message: '时间已经到了哦',
        duration: 1000,
        position: 'bottom-right'
      });
    },
    clickFn() {
      this.$refs.statistic.suspend(this.stop);
      this.stop = !this.stop;
      // console.log(this.stop);
    },

    add() {
      this.deadline4 = this.deadline4 + 1000 * 60 * 1;
      console.log(this.deadline4);
    },

    render() {
      axios({
        url: '/dbdata/woman',
      }).then(({ data }) => {

        this.woman = data
        this.activeIndex = 0;
        this.subFoodList = this.woman[0].children;
        // this.imgArr.push({ img: v.avatar, title: v.name, path: "/happyhome/home/FriendChata" })
        //  this.tableData = this.totalData.slice((this.currentPage4 - 1) * this.limit, this.currentPage4 * this.limit)

      });
    },

    btnClick(index) {
      console.log("ok");
      this.activeIndex = index;
      this.subFoodList = this.woman[index].children;

      console.log(this.activeIndex);

    },
  },
  // created() {
  //     this.subFoodList = this.foodList[this.activeIndex].children;

  // },
  mounted() {
    this.render();



  },
};
</script>
<style lang="less" scoped>
.contain {
    //   display: flex;
    background: url('../../assets/image/zlj/bg.gif');
    height: 100%;
    width: 100%;
    color: #ffffff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    position: relative;
    z-index: 0;

}
.jielu {
  display: flex;
  width: 150px;
  //    display: inline-block;
  margin-left: 20px;
  cursor: pointer;
  justify-content: space-between;

  // border: 1px solid red;
  p {
    color: #000;

    &:hover {
      color: #007bff;
    }
  }
}

.father {
  display: flex;
  justify-content: space-between;
  width: 400px;
  height: 40px;
  padding-left: 20px;
  margin-bottom: 20px;
  // background-color: rgb(0, 0, 0);
  color: #000;
  border-radius: 10px;

  .time {
    line-height: 40px;
  }

  ul {
    padding-right: 7px;
  }

  ul li {
    list-style: none;
    text-align: center;
    padding-right: 10px;
    float: left;
  }

  .el-button {
    width: 80px;
    height: 40px;
  }
}

.el-pagination {
  padding-right: 75%;
  padding-bottom: 10px;
}

.img {
  float: left;
  width: 270px;
  margin-top: 20px;
  height: 400px;
  margin-bottom: 40px;
  color: #000000;
  border: 2px solid rgba(177, 226, 255, 0.588);
  border-radius: 2em;
  margin-right: 25px;

  .video {
    border-radius: 2em 2em 0.25em 0.25em;
    // margin-top: -20px;
    overflow: hidden;
    width: 270px;
    height: 200px;
    margin-top: 0;
  }

  &:hover {

    box-shadow: 3px 5px 5px rgba(255, 251, 212, 0.924);
  }

  .el-button {
    margin-top: 10px;
  }

}

.itt {
  color: #ffffff;
  margin: auto;
  text-align: center;
  margin-top: 10px;
  width: 260px;
  height: 110px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

video {
  object-fit: fill;
}

.contain {
  color: #000000;
  background-color: rgba(244, 215, 215, 0.439);
  height: 100%;
  width: 100%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  position: relative;
  z-index: 0;

}



.img-b-a {
  display: flex;
  justify-content: space-between;
}

.aa {
  // margin-bottom: 20px;
  margin-top: 20px;
  float: left;
  margin-left: 60px;
  border-radius: 5px;
}

.main {
  width: 98%;
  display: flex;
  height: 100%;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-left: 2%;
}



.lwy-back {
  text-align: left;
  margin-left: 5px;
  margin-top: 20px;

  a:-webkit-any-link {
    color: rgba(00, 00, 00, 0.67);
    text-decoration: none;

    .el-icon-arrow-left {
      margin-right: 5px;
    }
  }

}

.el-button--primary {
  background-color: rgb(255, 233, 192);
  color: rgba(00, 00, 00, 0.8);
  border-color: rgb(255, 233, 192);
}

.el-button--primary:hover {
  background-color: rgba(255, 233, 192, 0.8);
  color: rgba(00, 00, 00, 0.5);
  border-color: rgba(255, 233, 192, 0.8);
}
</style>
